home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / pjc_asm.arc / PJ4-L1.ASM < prev    next >
Assembly Source File  |  1987-12-12  |  2KB  |  75 lines

  1. ; Listing 1.
  2. ; Program to illustrate operation of Map Mask register when drawing
  3. ;  to memory that already contains data.
  4. ; Assembled with MASM 4.0, linked with LINK 3.51.
  5. ; Copyright by Michael Abrash, 4/26/87.
  6. ;
  7. stack    segment    para stack 'STACK'
  8.     db    512 dup(?)
  9. stack    ends
  10. ;
  11. EGA_VIDEO_SEGMENT    equ    0a000h    ;EGA display memory segment
  12. ;
  13. ; EGA register equates.
  14. ;
  15. TS_INDEX    equ    3c4h    ;TS index register
  16. TS_MAP_MASK    equ    2    ;TS map mask register
  17. ;
  18. ; Macro to set indexed register INDEX of TS chip to SETTING.
  19. ;
  20. SETTS    macro    INDEX, SETTING
  21.     mov    dx,TS_INDEX
  22.     mov    al,INDEX
  23.     out    dx,al
  24.     inc    dx
  25.     mov    al,SETTING
  26.     out    dx,al
  27.     dec    dx
  28.     endm
  29. ;
  30. cseg    segment    para public 'CODE'
  31.     assume    cs:cseg
  32. start    proc    near
  33. ;
  34. ; Select 640x350 graphics mode.
  35. ;
  36.     mov    ax,010h
  37.     int    10h
  38. ;
  39.     mov    ax,EGA_VIDEO_SEGMENT
  40.     mov    es,ax            ;point to video memory
  41. ;
  42. ; Draw 18 10-scan-line high horizontal bars in green, 10 scan lines apart.
  43. ;
  44.     SETTS    TS_MAP_MASK,02h        ;map mask setting enables only
  45.                     ; plane 1, the green plane
  46.     sub    di,di        ;start at beginning of video memory
  47.     mov    al,0ffh
  48.     mov    bp,18        ;# bars to draw
  49. HorzBarLoop:
  50.     mov    cx,80*10    ;# bytes per horizontal bar
  51.     rep stosb        ;draw bar
  52.     add    di,80*10    ;point to start of next bar
  53.     dec    bp
  54.     jnz    HorzBarLoop
  55. ;
  56. ; Fill screen with blue, using Map Mask register to enable writes
  57. ; to blue plane only.
  58. ;
  59.     SETTS    TS_MAP_MASK,01h        ;map mask setting enables only
  60.                     ; plane 0, the blue plane
  61.     sub    di,di
  62.     mov    cx,80*350        ;# bytes per screen
  63.     mov    al,0ffh
  64.     rep stosb            ;perform fill (affects only
  65.                     ; plane 0, the blue plane)
  66. ;
  67. ; Exit to DOS.
  68. ;
  69.     mov    ah,4ch
  70.     int    21h
  71. start    endp
  72. cseg    ends
  73.     end    start
  74.  
  75.